<!DOCTYPE html>

<html>
  <head>
    <meta charset="utf-8">
    
    <title>Random sampling (numpy.random) &mdash; NumPy v1.18 Manual</title>
    
    <link rel="stylesheet" type="text/css" href="../../_static/css/spc-bootstrap.css">
    <link rel="stylesheet" type="text/css" href="../../_static/css/spc-extend.css">
    <link rel="stylesheet" href="../../_static/scipy.css" type="text/css" >
    <link rel="stylesheet" href="../../_static/pygments.css" type="text/css" >
    <link rel="stylesheet" href="../../_static/graphviz.css" type="text/css" >
    
    <script type="text/javascript">
      var DOCUMENTATION_OPTIONS = {
        URL_ROOT:    '../../',
        VERSION:     '1.18.1',
        COLLAPSE_INDEX: false,
        FILE_SUFFIX: '.html',
        HAS_SOURCE:  false
      };
    </script>
    <script type="text/javascript" src="../../_static/jquery.js"></script>
    <script type="text/javascript" src="../../_static/underscore.js"></script>
    <script type="text/javascript" src="../../_static/doctools.js"></script>
    <script type="text/javascript" src="../../_static/language_data.js"></script>
    <script type="text/javascript" src="../../_static/js/copybutton.js"></script>
    <link rel="author" title="About these documents" href="../../about.html" >
    <link rel="index" title="Index" href="../../genindex.html" >
    <link rel="search" title="Search" href="../../search.html" >
    <link rel="top" title="NumPy v1.18 Manual" href="../../index.html" >
    <link rel="up" title="Routines" href="../routines.html" >
    <link rel="next" title="Random Generator" href="generator.html" >
    <link rel="prev" title="numpy.RankWarning" href="../generated/numpy.RankWarning.html" > 
  </head>
  <body>
<div class="container">
  <div class="top-scipy-org-logo-header" style="background-color: #a2bae8;">
    <a href="../../index.html">
      <img border=0 alt="NumPy" src="../../_static/numpy_logo.png"></a>
    </div>
  </div>
</div>


    <div class="container">
      <div class="main">
        
	<div class="row-fluid">
	  <div class="span12">
	    <div class="spc-navbar">
              
    <ul class="nav nav-pills pull-left">
        <li class="active"><a href="https://numpy.org/">NumPy.org</a></li>
        <li class="active"><a href="https://numpy.org/doc">Docs</a></li>
        
        <li class="active"><a href="../../index.html">NumPy v1.18 Manual</a></li>
        

          <li class="active"><a href="../index.html" >NumPy Reference</a></li>
          <li class="active"><a href="../routines.html" accesskey="U">Routines</a></li> 
    </ul>
              
              
    <ul class="nav nav-pills pull-right">
      <li class="active">
        <a href="../../genindex.html" title="General Index"
           accesskey="I">index</a>
      </li>
      <li class="active">
        <a href="generator.html" title="Random Generator"
           accesskey="N">next</a>
      </li>
      <li class="active">
        <a href="../generated/numpy.RankWarning.html" title="numpy.RankWarning"
           accesskey="P">previous</a>
      </li>
    </ul>
              
	    </div>
	  </div>
	</div>
        

	<div class="row-fluid">
      <div class="spc-rightsidebar span3">
        <div class="sphinxsidebarwrapper">
  <h3><a href="../../contents.html">Table of Contents</a></h3>
  <ul>
<li><a class="reference internal" href="#">Random sampling (<code class="xref py py-mod docutils literal notranslate"><span class="pre">numpy.random</span></code>)</a><ul>
<li><a class="reference internal" href="#quick-start">Quick Start</a></li>
<li><a class="reference internal" href="#introduction">Introduction</a><ul>
<li><a class="reference internal" href="#what-s-new-or-different">What’s New or Different</a></li>
<li><a class="reference internal" href="#parallel-generation">Parallel Generation</a></li>
</ul>
</li>
<li><a class="reference internal" href="#concepts">Concepts</a></li>
<li><a class="reference internal" href="#features">Features</a><ul>
<li><a class="reference internal" href="#original-source-of-the-generator-and-bitgenerators">Original Source of the Generator and BitGenerators</a></li>
</ul>
</li>
</ul>
</li>
</ul>

  <h4>Previous topic</h4>
  <p class="topless"><a href="../generated/numpy.RankWarning.html"
                        title="previous chapter">numpy.RankWarning</a></p>
  <h4>Next topic</h4>
  <p class="topless"><a href="generator.html"
                        title="next chapter">Random Generator</a></p>
<div id="searchbox" style="display: none" role="search">
  <h4>Quick search</h4>
    <div>
    <form class="search" action="../../search.html" method="get">
      <input type="text" style="width: inherit;" name="q" />
      <input type="submit" value="search" />
      <input type="hidden" name="check_keywords" value="yes" />
      <input type="hidden" name="area" value="default" />
    </form>
    </div>
</div>
<script type="text/javascript">$('#searchbox').show(0);</script>
        </div>
      </div>
          <div class="span9">
            
        <div class="bodywrapper">
          <div class="body" id="spc-section-body">
            
  <span class="target" id="module-numpy.random"><span id="numpyrandom"></span></span><div class="section" id="random-sampling-numpy-random">
<h1>Random sampling (<a class="reference internal" href="#module-numpy.random" title="numpy.random"><code class="xref py py-mod docutils literal notranslate"><span class="pre">numpy.random</span></code></a>)<a class="headerlink" href="#random-sampling-numpy-random" title="Permalink to this headline">¶</a></h1>
<p>Numpy’s random number routines produce pseudo random numbers using
combinations of a <a class="reference internal" href="bit_generators/generated/numpy.random.BitGenerator.html#numpy.random.BitGenerator" title="numpy.random.BitGenerator"><code class="xref py py-obj docutils literal notranslate"><span class="pre">BitGenerator</span></code></a> to create sequences and a <a class="reference internal" href="generator.html#numpy.random.Generator" title="numpy.random.Generator"><code class="xref py py-obj docutils literal notranslate"><span class="pre">Generator</span></code></a>
to use those sequences to sample from different statistical distributions:</p>
<ul class="simple">
<li><p>BitGenerators: Objects that generate random numbers. These are typically
unsigned integer words filled with sequences of either 32 or 64 random bits.</p></li>
<li><p>Generators: Objects that transform sequences of random bits from a
BitGenerator into sequences of numbers that follow a specific probability
distribution (such as uniform, Normal or Binomial) within a specified
interval.</p></li>
</ul>
<p>Since Numpy version 1.17.0 the Generator can be initialized with a
number of different BitGenerators. It exposes many different probability
distributions. See <a class="reference external" href="https://www.numpy.org/neps/nep-0019-rng-policy.html">NEP 19</a> for context on the updated random Numpy number
routines. The legacy <a class="reference internal" href="legacy.html#numpy.random.RandomState" title="numpy.random.RandomState"><code class="xref py py-obj docutils literal notranslate"><span class="pre">RandomState</span></code></a> random number routines are still
available, but limited to a single BitGenerator.</p>
<p>For convenience and backward compatibility, a single <a class="reference internal" href="legacy.html#numpy.random.RandomState" title="numpy.random.RandomState"><code class="xref py py-obj docutils literal notranslate"><span class="pre">RandomState</span></code></a>
instance’s methods are imported into the numpy.random namespace, see
<a class="reference internal" href="legacy.html#legacy"><span class="std std-ref">Legacy Random Generation</span></a> for the complete list.</p>
<div class="section" id="quick-start">
<span id="random-quick-start"></span><h2>Quick Start<a class="headerlink" href="#quick-start" title="Permalink to this headline">¶</a></h2>
<p>Call <a class="reference internal" href="generator.html#numpy.random.default_rng" title="numpy.random.default_rng"><code class="xref py py-obj docutils literal notranslate"><span class="pre">default_rng</span></code></a> to get a new instance of a <a class="reference internal" href="generator.html#numpy.random.Generator" title="numpy.random.Generator"><code class="xref py py-obj docutils literal notranslate"><span class="pre">Generator</span></code></a>, then call its
methods to obtain samples from different distributions.  By default,
<a class="reference internal" href="generator.html#numpy.random.Generator" title="numpy.random.Generator"><code class="xref py py-obj docutils literal notranslate"><span class="pre">Generator</span></code></a> uses bits provided by <a class="reference internal" href="bit_generators/pcg64.html#numpy.random.PCG64" title="numpy.random.PCG64"><code class="xref py py-obj docutils literal notranslate"><span class="pre">PCG64</span></code></a> which has better statistical
properties than the legacy <a class="reference internal" href="bit_generators/mt19937.html#numpy.random.MT19937" title="numpy.random.MT19937"><code class="xref py py-obj docutils literal notranslate"><span class="pre">MT19937</span></code></a> used in <a class="reference internal" href="legacy.html#numpy.random.RandomState" title="numpy.random.RandomState"><code class="xref py py-obj docutils literal notranslate"><span class="pre">RandomState</span></code></a>.</p>
<div class="highlight-python notranslate"><div class="highlight"><pre><span></span><span class="c1"># Do this</span>
<span class="kn">from</span> <span class="nn">numpy.random</span> <span class="kn">import</span> <span class="n">default_rng</span>
<span class="n">rng</span> <span class="o">=</span> <span class="n">default_rng</span><span class="p">()</span>
<span class="n">vals</span> <span class="o">=</span> <span class="n">rng</span><span class="o">.</span><span class="n">standard_normal</span><span class="p">(</span><span class="mi">10</span><span class="p">)</span>
<span class="n">more_vals</span> <span class="o">=</span> <span class="n">rng</span><span class="o">.</span><span class="n">standard_normal</span><span class="p">(</span><span class="mi">10</span><span class="p">)</span>

<span class="c1"># instead of this</span>
<span class="kn">from</span> <span class="nn">numpy</span> <span class="kn">import</span> <span class="n">random</span>
<span class="n">vals</span> <span class="o">=</span> <span class="n">random</span><span class="o">.</span><span class="n">standard_normal</span><span class="p">(</span><span class="mi">10</span><span class="p">)</span>
<span class="n">more_vals</span> <span class="o">=</span> <span class="n">random</span><span class="o">.</span><span class="n">standard_normal</span><span class="p">(</span><span class="mi">10</span><span class="p">)</span>
</pre></div>
</div>
<p><a class="reference internal" href="generator.html#numpy.random.Generator" title="numpy.random.Generator"><code class="xref py py-obj docutils literal notranslate"><span class="pre">Generator</span></code></a> can be used as a replacement for <a class="reference internal" href="legacy.html#numpy.random.RandomState" title="numpy.random.RandomState"><code class="xref py py-obj docutils literal notranslate"><span class="pre">RandomState</span></code></a>. Both class
instances hold a internal <a class="reference internal" href="bit_generators/generated/numpy.random.BitGenerator.html#numpy.random.BitGenerator" title="numpy.random.BitGenerator"><code class="xref py py-obj docutils literal notranslate"><span class="pre">BitGenerator</span></code></a> instance to provide the bit
stream, it is accessible as <code class="docutils literal notranslate"><span class="pre">gen.bit_generator</span></code>. Some long-overdue API
cleanup means that legacy and compatibility methods have been removed from
<a class="reference internal" href="generator.html#numpy.random.Generator" title="numpy.random.Generator"><code class="xref py py-obj docutils literal notranslate"><span class="pre">Generator</span></code></a></p>
<table class="docutils align-default">
<colgroup>
<col style="width: 25%" />
<col style="width: 19%" />
<col style="width: 56%" />
</colgroup>
<tbody>
<tr class="row-odd"><td><p><a class="reference internal" href="legacy.html#numpy.random.RandomState" title="numpy.random.RandomState"><code class="xref py py-obj docutils literal notranslate"><span class="pre">RandomState</span></code></a></p></td>
<td><p><a class="reference internal" href="generator.html#numpy.random.Generator" title="numpy.random.Generator"><code class="xref py py-obj docutils literal notranslate"><span class="pre">Generator</span></code></a></p></td>
<td><p>Notes</p></td>
</tr>
<tr class="row-even"><td><p><code class="docutils literal notranslate"><span class="pre">random_sample</span></code>,</p></td>
<td><p><code class="docutils literal notranslate"><span class="pre">random</span></code></p></td>
<td><p>Compatible with <a class="reference external" href="https://docs.python.org/dev/library/random.html#random.random" title="(in Python v3.9)"><code class="xref py py-obj docutils literal notranslate"><span class="pre">random.random</span></code></a></p></td>
</tr>
<tr class="row-odd"><td><p><code class="docutils literal notranslate"><span class="pre">rand</span></code></p></td>
<td></td>
<td></td>
</tr>
<tr class="row-even"><td><p><code class="docutils literal notranslate"><span class="pre">randint</span></code>,</p></td>
<td><p><code class="docutils literal notranslate"><span class="pre">integers</span></code></p></td>
<td><p>Add an <code class="docutils literal notranslate"><span class="pre">endpoint</span></code> kwarg</p></td>
</tr>
<tr class="row-odd"><td><p><code class="docutils literal notranslate"><span class="pre">random_integers</span></code></p></td>
<td></td>
<td></td>
</tr>
<tr class="row-even"><td><p><code class="docutils literal notranslate"><span class="pre">tomaxint</span></code></p></td>
<td><p>removed</p></td>
<td><p>Use <code class="docutils literal notranslate"><span class="pre">integers(0,</span> <span class="pre">np.iinfo(np.int_).max,</span></code>
<code class="docutils literal notranslate"><span class="pre">endpoint=False)</span></code></p></td>
</tr>
<tr class="row-odd"><td><p><code class="docutils literal notranslate"><span class="pre">seed</span></code></p></td>
<td><p>removed</p></td>
<td><p>Use <a class="reference internal" href="bit_generators/generated/numpy.random.SeedSequence.spawn.html#numpy.random.SeedSequence.spawn" title="numpy.random.SeedSequence.spawn"><code class="xref py py-obj docutils literal notranslate"><span class="pre">SeedSequence.spawn</span></code></a></p></td>
</tr>
</tbody>
</table>
<p>See <a class="reference internal" href="new-or-different.html#new-or-different"><span class="std std-ref">What’s New or Different</span></a> for more information</p>
<p>Something like the following code can be used to support both <code class="docutils literal notranslate"><span class="pre">RandomState</span></code>
and <code class="docutils literal notranslate"><span class="pre">Generator</span></code>, with the understanding that the interfaces are slightly
different</p>
<div class="highlight-python notranslate"><div class="highlight"><pre><span></span><span class="k">try</span><span class="p">:</span>
    <span class="n">rg_integers</span> <span class="o">=</span> <span class="n">rg</span><span class="o">.</span><span class="n">integers</span>
<span class="k">except</span> <span class="ne">AttributeError</span><span class="p">:</span>
    <span class="n">rg_integers</span> <span class="o">=</span> <span class="n">rg</span><span class="o">.</span><span class="n">randint</span>
<span class="n">a</span> <span class="o">=</span> <span class="n">rg_integers</span><span class="p">(</span><span class="mi">1000</span><span class="p">)</span>
</pre></div>
</div>
<p>Seeds can be passed to any of the BitGenerators. The provided value is mixed
via <a class="reference internal" href="bit_generators/generated/numpy.random.SeedSequence.html#numpy.random.SeedSequence" title="numpy.random.SeedSequence"><code class="xref py py-obj docutils literal notranslate"><span class="pre">SeedSequence</span></code></a> to spread a possible sequence of seeds across a wider
range of initialization states for the BitGenerator. Here <a class="reference internal" href="bit_generators/pcg64.html#numpy.random.PCG64" title="numpy.random.PCG64"><code class="xref py py-obj docutils literal notranslate"><span class="pre">PCG64</span></code></a> is used and
is wrapped with a <a class="reference internal" href="generator.html#numpy.random.Generator" title="numpy.random.Generator"><code class="xref py py-obj docutils literal notranslate"><span class="pre">Generator</span></code></a>.</p>
<div class="highlight-python notranslate"><div class="highlight"><pre><span></span><span class="kn">from</span> <span class="nn">numpy.random</span> <span class="kn">import</span> <span class="n">Generator</span><span class="p">,</span> <span class="n">PCG64</span>
<span class="n">rg</span> <span class="o">=</span> <span class="n">Generator</span><span class="p">(</span><span class="n">PCG64</span><span class="p">(</span><span class="mi">12345</span><span class="p">))</span>
<span class="n">rg</span><span class="o">.</span><span class="n">standard_normal</span><span class="p">()</span>
</pre></div>
</div>
</div>
<div class="section" id="introduction">
<h2>Introduction<a class="headerlink" href="#introduction" title="Permalink to this headline">¶</a></h2>
<p>The new infrastructure takes a different approach to producing random numbers
from the <a class="reference internal" href="legacy.html#numpy.random.RandomState" title="numpy.random.RandomState"><code class="xref py py-obj docutils literal notranslate"><span class="pre">RandomState</span></code></a> object.  Random number generation is separated into
two components, a bit generator and a random generator.</p>
<p>The <a class="reference internal" href="bit_generators/generated/numpy.random.BitGenerator.html#numpy.random.BitGenerator" title="numpy.random.BitGenerator"><code class="xref py py-obj docutils literal notranslate"><span class="pre">BitGenerator</span></code></a> has a limited set of responsibilities. It manages state
and provides functions to produce random doubles and random unsigned 32- and
64-bit values.</p>
<p>The <a class="reference internal" href="generator.html#numpy.random.Generator" title="numpy.random.Generator"><code class="xref py py-obj docutils literal notranslate"><span class="pre">random</span> <span class="pre">generator</span></code></a> takes the
bit generator-provided stream and transforms them into more useful
distributions, e.g., simulated normal random values. This structure allows
alternative bit generators to be used with little code duplication.</p>
<p>The <a class="reference internal" href="generator.html#numpy.random.Generator" title="numpy.random.Generator"><code class="xref py py-obj docutils literal notranslate"><span class="pre">Generator</span></code></a> is the user-facing object that is nearly identical to
<a class="reference internal" href="legacy.html#numpy.random.RandomState" title="numpy.random.RandomState"><code class="xref py py-obj docutils literal notranslate"><span class="pre">RandomState</span></code></a>. The canonical method to initialize a generator passes a
<a class="reference internal" href="bit_generators/pcg64.html#numpy.random.PCG64" title="numpy.random.PCG64"><code class="xref py py-obj docutils literal notranslate"><span class="pre">PCG64</span></code></a> bit generator as the sole argument.</p>
<div class="highlight-python notranslate"><div class="highlight"><pre><span></span><span class="kn">from</span> <span class="nn">numpy.random</span> <span class="kn">import</span> <span class="n">default_rng</span>
<span class="n">rg</span> <span class="o">=</span> <span class="n">default_rng</span><span class="p">(</span><span class="mi">12345</span><span class="p">)</span>
<span class="n">rg</span><span class="o">.</span><span class="n">random</span><span class="p">()</span>
</pre></div>
</div>
<p>One can also instantiate <a class="reference internal" href="generator.html#numpy.random.Generator" title="numpy.random.Generator"><code class="xref py py-obj docutils literal notranslate"><span class="pre">Generator</span></code></a> directly with a <a class="reference internal" href="bit_generators/generated/numpy.random.BitGenerator.html#numpy.random.BitGenerator" title="numpy.random.BitGenerator"><code class="xref py py-obj docutils literal notranslate"><span class="pre">BitGenerator</span></code></a> instance.
To use the older <a class="reference internal" href="bit_generators/mt19937.html#numpy.random.MT19937" title="numpy.random.MT19937"><code class="xref py py-obj docutils literal notranslate"><span class="pre">MT19937</span></code></a> algorithm, one can instantiate it directly
and pass it to <a class="reference internal" href="generator.html#numpy.random.Generator" title="numpy.random.Generator"><code class="xref py py-obj docutils literal notranslate"><span class="pre">Generator</span></code></a>.</p>
<div class="highlight-python notranslate"><div class="highlight"><pre><span></span><span class="kn">from</span> <span class="nn">numpy.random</span> <span class="kn">import</span> <span class="n">Generator</span><span class="p">,</span> <span class="n">MT19937</span>
<span class="n">rg</span> <span class="o">=</span> <span class="n">Generator</span><span class="p">(</span><span class="n">MT19937</span><span class="p">(</span><span class="mi">12345</span><span class="p">))</span>
<span class="n">rg</span><span class="o">.</span><span class="n">random</span><span class="p">()</span>
</pre></div>
</div>
<div class="section" id="what-s-new-or-different">
<h3>What’s New or Different<a class="headerlink" href="#what-s-new-or-different" title="Permalink to this headline">¶</a></h3>
<div class="admonition warning">
<p class="admonition-title">Warning</p>
<p>The Box-Muller method used to produce NumPy’s normals is no longer available
in <a class="reference internal" href="generator.html#numpy.random.Generator" title="numpy.random.Generator"><code class="xref py py-obj docutils literal notranslate"><span class="pre">Generator</span></code></a>.  It is not possible to reproduce the exact random
values using Generator for the normal distribution or any other
distribution that relies on the normal such as the <a class="reference internal" href="generated/numpy.random.RandomState.gamma.html#numpy.random.RandomState.gamma" title="numpy.random.RandomState.gamma"><code class="xref py py-obj docutils literal notranslate"><span class="pre">RandomState.gamma</span></code></a> or
<a class="reference internal" href="generated/numpy.random.RandomState.standard_t.html#numpy.random.RandomState.standard_t" title="numpy.random.RandomState.standard_t"><code class="xref py py-obj docutils literal notranslate"><span class="pre">RandomState.standard_t</span></code></a>. If you require bitwise backward compatible
streams, use <a class="reference internal" href="legacy.html#numpy.random.RandomState" title="numpy.random.RandomState"><code class="xref py py-obj docutils literal notranslate"><span class="pre">RandomState</span></code></a>.</p>
</div>
<ul class="simple">
<li><p>The Generator’s normal, exponential and gamma functions use 256-step Ziggurat
methods which are 2-10 times faster than NumPy’s Box-Muller or inverse CDF
implementations.</p></li>
<li><p>Optional <code class="docutils literal notranslate"><span class="pre">dtype</span></code> argument that accepts <code class="docutils literal notranslate"><span class="pre">np.float32</span></code> or <code class="docutils literal notranslate"><span class="pre">np.float64</span></code>
to produce either single or double prevision uniform random variables for
select distributions</p></li>
<li><p>Optional <code class="docutils literal notranslate"><span class="pre">out</span></code> argument that allows existing arrays to be filled for
select distributions</p></li>
<li><p>All BitGenerators can produce doubles, uint64s and uint32s via CTypes
(<a class="reference internal" href="bit_generators/generated/numpy.random.PCG64.ctypes.html#numpy.random.PCG64.ctypes" title="numpy.random.PCG64.ctypes"><code class="xref py py-obj docutils literal notranslate"><span class="pre">PCG64.ctypes</span></code></a>) and CFFI (<a class="reference internal" href="bit_generators/generated/numpy.random.PCG64.cffi.html#numpy.random.PCG64.cffi" title="numpy.random.PCG64.cffi"><code class="xref py py-obj docutils literal notranslate"><span class="pre">PCG64.cffi</span></code></a>). This allows the bit generators
to be used in numba.</p></li>
<li><p>The bit generators can be used in downstream projects via
<a class="reference internal" href="extending.html#random-cython"><span class="std std-ref">Cython</span></a>.</p></li>
<li><p><a class="reference internal" href="generated/numpy.random.Generator.integers.html#numpy.random.Generator.integers" title="numpy.random.Generator.integers"><code class="xref py py-obj docutils literal notranslate"><span class="pre">Generator.integers</span></code></a> is now the canonical way to generate integer
random numbers from a discrete uniform distribution. The <code class="docutils literal notranslate"><span class="pre">rand</span></code> and
<code class="docutils literal notranslate"><span class="pre">randn</span></code> methods are only available through the legacy <a class="reference internal" href="legacy.html#numpy.random.RandomState" title="numpy.random.RandomState"><code class="xref py py-obj docutils literal notranslate"><span class="pre">RandomState</span></code></a>.
The <code class="docutils literal notranslate"><span class="pre">endpoint</span></code> keyword can be used to specify open or closed intervals.
This replaces both <code class="docutils literal notranslate"><span class="pre">randint</span></code> and the deprecated <code class="docutils literal notranslate"><span class="pre">random_integers</span></code>.</p></li>
<li><p><a class="reference internal" href="generated/numpy.random.Generator.random.html#numpy.random.Generator.random" title="numpy.random.Generator.random"><code class="xref py py-obj docutils literal notranslate"><span class="pre">Generator.random</span></code></a> is now the canonical way to generate floating-point
random numbers, which replaces <a class="reference internal" href="generated/numpy.random.RandomState.random_sample.html#numpy.random.RandomState.random_sample" title="numpy.random.RandomState.random_sample"><code class="xref py py-obj docutils literal notranslate"><span class="pre">RandomState.random_sample</span></code></a>,
<em class="xref py py-obj">RandomState.sample</em>, and <em class="xref py py-obj">RandomState.ranf</em>. This is consistent with
Python’s <a class="reference external" href="https://docs.python.org/dev/library/random.html#random.random" title="(in Python v3.9)"><code class="xref py py-obj docutils literal notranslate"><span class="pre">random.random</span></code></a>.</p></li>
<li><p>All BitGenerators in numpy use <a class="reference internal" href="bit_generators/generated/numpy.random.SeedSequence.html#numpy.random.SeedSequence" title="numpy.random.SeedSequence"><code class="xref py py-obj docutils literal notranslate"><span class="pre">SeedSequence</span></code></a> to convert seeds into
initialized states.</p></li>
</ul>
<p>See <a class="reference internal" href="new-or-different.html#new-or-different"><span class="std std-ref">What’s New or Different</span></a> for a complete list of improvements and
differences from the traditional <code class="docutils literal notranslate"><span class="pre">Randomstate</span></code>.</p>
</div>
<div class="section" id="parallel-generation">
<h3>Parallel Generation<a class="headerlink" href="#parallel-generation" title="Permalink to this headline">¶</a></h3>
<p>The included generators can be used in parallel, distributed applications in
one of three ways:</p>
<ul class="simple">
<li><p><a class="reference internal" href="parallel.html#seedsequence-spawn"><span class="std std-ref">SeedSequence spawning</span></a></p></li>
<li><p><a class="reference internal" href="parallel.html#independent-streams"><span class="std std-ref">Independent Streams</span></a></p></li>
<li><p><a class="reference internal" href="parallel.html#parallel-jumped"><span class="std std-ref">Jumping the BitGenerator state</span></a></p></li>
</ul>
</div>
</div>
<div class="section" id="concepts">
<h2>Concepts<a class="headerlink" href="#concepts" title="Permalink to this headline">¶</a></h2>
<div class="toctree-wrapper compound">
<ul>
<li class="toctree-l1"><a class="reference internal" href="generator.html">Random Generator</a></li>
<li class="toctree-l1"><a class="reference internal" href="legacy.html">Legacy Generator (RandomState)</a></li>
<li class="toctree-l1"><a class="reference internal" href="bit_generators/index.html">Bit Generators</a></li>
<li class="toctree-l1"><a class="reference internal" href="bit_generators/index.html#seeding-and-entropy">Seeding and Entropy</a></li>
</ul>
</div>
</div>
<div class="section" id="features">
<h2>Features<a class="headerlink" href="#features" title="Permalink to this headline">¶</a></h2>
<div class="toctree-wrapper compound">
<ul>
<li class="toctree-l1"><a class="reference internal" href="parallel.html">Parallel Applications</a><ul>
<li class="toctree-l2"><a class="reference internal" href="parallel.html#seedsequence-spawning"><code class="xref py py-obj docutils literal notranslate"><span class="pre">SeedSequence</span></code> spawning</a></li>
<li class="toctree-l2"><a class="reference internal" href="parallel.html#independent-streams">Independent Streams</a></li>
<li class="toctree-l2"><a class="reference internal" href="parallel.html#jumping-the-bitgenerator-state">Jumping the BitGenerator state</a></li>
</ul>
</li>
<li class="toctree-l1"><a class="reference internal" href="multithreading.html">Multithreaded Generation</a></li>
<li class="toctree-l1"><a class="reference internal" href="new-or-different.html">What’s New or Different</a></li>
<li class="toctree-l1"><a class="reference internal" href="performance.html">Comparing Performance</a><ul>
<li class="toctree-l2"><a class="reference internal" href="performance.html#recommendation">Recommendation</a></li>
<li class="toctree-l2"><a class="reference internal" href="performance.html#timings">Timings</a></li>
<li class="toctree-l2"><a class="reference internal" href="performance.html#performance-on-different-operating-systems">Performance on different Operating Systems</a></li>
</ul>
</li>
<li class="toctree-l1"><a class="reference internal" href="c-api.html">Cython API for random</a></li>
<li class="toctree-l1"><a class="reference internal" href="c-api.html#c-api-for-random">C API for random</a></li>
<li class="toctree-l1"><a class="reference internal" href="extending.html">Examples of using Numba, Cython, CFFI</a><ul>
<li class="toctree-l2"><a class="reference internal" href="extending.html#numba">Numba</a></li>
<li class="toctree-l2"><a class="reference internal" href="extending.html#cython">Cython</a></li>
<li class="toctree-l2"><a class="reference internal" href="extending.html#cffi">CFFI</a></li>
<li class="toctree-l2"><a class="reference internal" href="extending.html#new-basic-rngs">New Basic RNGs</a></li>
<li class="toctree-l2"><a class="reference internal" href="extending.html#examples">Examples</a></li>
</ul>
</li>
</ul>
</div>
<div class="section" id="original-source-of-the-generator-and-bitgenerators">
<h3>Original Source of the Generator and BitGenerators<a class="headerlink" href="#original-source-of-the-generator-and-bitgenerators" title="Permalink to this headline">¶</a></h3>
<p>This package was developed independently of NumPy and was integrated in version
1.17.0. The original repo is at <a class="reference external" href="https://github.com/bashtage/randomgen">https://github.com/bashtage/randomgen</a>.</p>
</div>
</div>
</div>


          </div>
        </div>
          </div>
        </div>
      </div>
    </div>

    <div class="container container-navbar-bottom">
      <div class="spc-navbar">
        
      </div>
    </div>
    <div class="container">
    <div class="footer">
    <div class="row-fluid">
    <ul class="inline pull-left">
      <li>
        &copy; Copyright 2008-2019, The SciPy community.
      </li>
      <li>
      Last updated on Feb 20, 2020.
      </li>
      <li>
      Created using <a href="http://sphinx.pocoo.org/">Sphinx</a> 2.4.2.
      </li>
    </ul>
    </div>
    </div>
    </div>
  </body>
</html>